import java.util.Scanner;

public class Practice {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        GirlFriend girl = new GirlFriend();
        while (true){
            try {
                System.out.println("请输入姓名");
                String name = sc.nextLine();
                girl.setName(name);
                System.out.println("请输入年龄");
                String ageStr = sc.nextLine();
                int age = Integer.parseInt(ageStr);
                girl.setAge(age);
                break;
            }catch (NumberFormatException e){
                e.printStackTrace();
            }catch (NameFormatException e){
                e.printStackTrace();
            }catch (AgeOutBoundsException e){
                e.printStackTrace();
            }
        }
        System.out.println(girl);

    }
}
